const { mongoose } = require("./db")
const Schema = mongoose.Schema


// 医生团队 (团队管理表)
const doctor_teamSchema = new Schema({
    name: String,   //签约医生团队,
    img: String, //头像
    tuan: String,//团长
    organ: {
        type: mongoose.Types.ObjectId,
        ref: "organ"
    },  //所属机构
    people: Number,  //签约人数
    rate: Number,  //评分
    state: Boolean, //状态
    tag: Array,  //团队标签
    bianhao:Number, //团队编号
})


// 服务包
const serve_packSchema = new Schema({
    name: String,
})


// 服务项目
const serve_projectSchema = new Schema({
    name: String
})


/* 

----------------------------------------------------------

*/


// 签约大表
const signSchema = new Schema({
    name: String,  //姓名
    ID: String, //身份证号
    mobile: String, //手机号
    team: {   //签约医生团队
        type: mongoose.Types.ObjectId,
        ref: "doctor_team"
    },
    serve: {   //签约服务包
        type: mongoose.Types.ObjectId,
        ref: "serve_pack"
    },
    state: Number,    //签约状态
    price:Number,
    orange:String,
    desc:String,
    cycle:String,
    time: { type: Date, default: Date.now },    //申请时间
})


// 服务大表
const serveSchema = new Schema({
    name: String,  //姓名
    ID: String, //身份证号
    mobile: String, //手机号

    serve: {   //签约服务包
        type: mongoose.Types.ObjectId,
        ref: "serve_pack"
    },
    project: {   //服务项目
        type: mongoose.Types.ObjectId,
        ref: "serve_project"
    },
    team: {   //服务医生
        type: mongoose.Types.ObjectId,
        ref: "doctor_team"
    },
    state: Number,    //服务状态
    time: { type: Date, default: Date.now },    //申请时间
})


const signModel = mongoose.model('sign', signSchema, "sign")   //签约大表
const serveModel = mongoose.model('serve', serveSchema, "serve")   //服务大表
const doctor_teamModel = mongoose.model('doctor_team', doctor_teamSchema, "doctor_team")    //医生团队
const serve_packModel = mongoose.model('serve_pack', serve_packSchema, "serve_pack")   //服务包
const serve_projectModel = mongoose.model('serve_project', serve_projectSchema, "serve_project")   //服务项目


// doctor_teamModel.create({
//     img: "http://localhost:3461/uploads/organ/1.png",
//     name: "王岸然团队",
//     tuan: "王岸然",
//     organ: "643fd661b4f5bdda954c92a2",
//     people: "601",
//     rate: "4.9",
//     state: true,
//     tag: [{ name: "高血压", color: "red" },{name:"糖尿病",color:"blue"}]
// })


module.exports = { serveModel, signModel, doctor_teamModel, serve_packModel, serve_projectModel }